package cloudAlibaba.controller;

import cloudAlibaba.myHandler.CustomerBlockHandler;
import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: Liuzihao
 * @Description:
 * @Date Created in 2022-05-05 21:03
 * @Modified By:
 */
@RestController
public class HelloController {

    @RequestMapping("helloA")
    String getA() throws InterruptedException {
        Thread.sleep(1000);
        System.out.println(Thread.currentThread().getName()+"/helloA");
        return "hello a";
    }

    @RequestMapping("helloB")
    String getB(){
        return "hello b";
    }


    @RequestMapping("helloC")
    @SentinelResource(value = "helloC",blockHandler = "getBDeal")
    String getC(String name,String address){
        return "hello C";
    }

    public String getBDeal(String name, String address, BlockException blockException){
        return "no hello C ";
    }


    @RequestMapping("helloD")
    @SentinelResource(value = "helloD",blockHandlerClass = CustomerBlockHandler.class,blockHandler = "blockHandler1")
    String getD(){
        return "hello D";
    }

    @RequestMapping("helloE")
    @SentinelResource(value = "helloE",blockHandlerClass = CustomerBlockHandler.class,blockHandler = "blockHandler2")
    String getE() throws InterruptedException {
        Thread.sleep(1000);
        return "hello E";
    }
}
